package com.example.springboot.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 功能：拦截器规则
 * 作者：陈雷
 * 日期：2024/10/24 20:51
 */

@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {

    @Override
    protected void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(jwtinterceptor())
                .addPathPatterns("/**")
                        .excludePathPatterns("/login","/user/banned");
                super.addInterceptors(registry);
    }
    @Bean
    public Jwtinterceptor jwtinterceptor(){
        return new Jwtinterceptor();
    }
}